import { useState, useEffect } from "react";
const useDebounce = (value: string, delay: number) => {
  const [val, setVal] = useState("");
  useEffect(() => {
    let timer = setTimeout(() => {
      setVal(value);
    });
    return () => {
      clearTimeout(timer);
    };
  }, [value, delay]);
  return val;
};
export default useDebounce;
